package com.lyk.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.common.dao.BaseDao;
import com.common.entity.A_customer;
import com.lyk.dao.A_customerDao;

public class A_customerDaoImpl extends BaseDao<A_customer> implements A_customerDao {

	@Override
	public List<A_customer> findByCondition(Map<String, Object> mp) {
		List<Object> paramList=new ArrayList<Object>();
		StringBuffer sf=new StringBuffer();
		sf.append(" select * from a_customer where 1=1 ");
		if(mp!=null && mp.size()>0){
			if(mp.get("atitle")!=null){
				sf.append("and title like ? ");
				paramList.add(mp.get("atitle"));
			}
		}
		return findBySql(sf.toString(), paramList.toArray());
	}

	@Override
	public int delA_customer(Integer n) {
		String sql = "delete a_customer where customer_id = ?";
		return this.executeUpdate(sql, new Object[]{n});
	}
	public A_customer getEntity(ResultSet rs){
		try {
			A_customer customer = new A_customer();
			customer.setCustomer_id(rs.getInt("customer_id"));
			customer.setCustomer_name(rs.getString("customer_name"));
			customer.setPwd(rs.getString("pwd"));
			customer.seteMail(rs.getString("eMail"));
			customer.setTelephone(rs.getString("telephone"));
			customer.setRealName(rs.getString("realName"));
			customer.setAddress(rs.getString("address"));
			customer.setCredit(rs.getInt("credit"));
			customer.setAssetLv_id(rs.getInt("assetLv_id"));
			customer.setAsset(rs.getLong("asset"));
			return customer;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
